//
// Created by haoly on 2025/5/24.
//

#include <assert.h>
#include <stdlib.h>

#include "ST.h"

Item create_item(Key, Value);
void test_insert();

int main(int argc, char *argv[]) {
    test_insert();
    return 0;
}

Item create_item(Key key, Value value) {
    Item x = malloc(sizeof(*x));
    x->key = key;
    x->value = value;
    return x;
}

void test_insert() {
    STinit(10);
    assert(STcount() == 0);

    Item A = create_item('A', 1);
    STinsert(A);
    assert(STcount() == 1);
    assert(value(STsearch('A')) == 1);

    Item S = create_item('S', 2);
    STinsert(S);
    assert(STcount() == 2);
    assert(value(STsearch('S')) == 2);

    Item E = create_item('E', 3);
    STinsert(E);
    assert(STcount() == 3);
    assert(value(STsearch('E')) == 3);

    Item R = create_item('R', 4);
    STinsert(R);
    assert(STcount() == 4);
    assert(value(STsearch('R')) == 4);

    Item C = create_item('C', 5);
    STinsert(C);
    assert(STcount() == 5);
    assert(value(STsearch('C')) == 5);

    Item H = create_item('H', 6);
    STinsert(H);
    assert(STcount() == 6);
    assert(value(STsearch('H')) == 6);

    Item I = create_item('I', 7);
    STinsert(I);
    assert(STcount() == 7);
    assert(value(STsearch('I')) == 7);

    Item N = create_item('N', 8);
    STinsert(N);
    assert(STcount() == 8);
    assert(value(STsearch('N')) == 8);


}
